#include "ManModbus.h"
#include "global.h"


BOOL ManModbus::LoadFromFlash(){

    return 1;
}

BOOL ManModbus::SaveToFlash(){


    return 1;
}



ManModbus::ManModbus(){
    address=2;
    baudrate=115200;
    x1=1;
    x2=1;
    isLeader=1;
    teamCount=1;
}

BOOL ManModbus::SetParam(WORD memId, Ndata* pSrcParam) {

    switch (memId) {
        case 1: address=pSrcParam->GetInt();break;
        case 2: baudrate=pSrcParam->GetInt();break;
        case 3: x1=pSrcParam->GetFloat();break;
        case 4: x2=pSrcParam->GetFloat();break;
        case 5: isLeader=pSrcParam->GetWord(); break;
        case 6: teamCount=pSrcParam->GetInt();break;
    }

    return true;
}


BOOL ManModbus::GetParam(WORD memId, Ndata* pDstParam) {

    switch (memId)
    {
        //class
        case 0: {
            pDstParam->SetDataBody(STR_TYPE, "Modbus", 16);
            break;
        }
            //address
        case 1: {
            pDstParam->SetDvb(Int2Dvb(address));
            break;
        }
            //baudrate
        case 2: {
            pDstParam->SetDvb(Int2Dvb(baudrate));
            break;
        }
            //x1
        case 3: {
            pDstParam->SetDvb(FreeFloat2Dvb(x1));
            break;
        }
            //x2
        case 4: {
            pDstParam->SetDvb(FreeFloat2Dvb(x2));
            break;
        }//isChild
        case 5: {
            pDstParam->SetWord(isLeader);
            break;
        }
            //nodeCount
        case 6: {
            pDstParam->SetDvb(Int2Dvb(teamCount));
            break;
        }
        default:
            break;
    }
    return true;
}

